package cn.shyouchi.wuguanjia.android.ui.home.security.thread.message.simplenotice;

import android.content.Intent;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.text.SimpleDateFormat;
import java.util.List;

import cn.shyouchi.wuguanjia.android.R;
import cn.shyouchi.wuguanjia.android.ui.attendance.AttendanceActivity;
import cn.shyouchi.wuguanjia.android.ui.home.security.thread.message.matter.MatterNoticeActivity;
import cn.shyouchi.wuguanjia.android.ui.meetting.plan.PlanMeetActivity;
import cn.shyouchi.wuguanjia.android.ui.patrol.PatrolActivity;
import cn.shyouchi.wuguanjia.android.ui.report.SelPostReportActivity;

/**
 * Created by Eenie on 2017/3/16 at 15:02
 * Email: 472279981@qq.com
 * Des:
 */

public class SampleNoticeAdapter extends BaseQuickAdapter<SampleNotice,BaseViewHolder> {

    public static final int NOTICE_ACTION_SIGN = 1001;
    public static final int NOTICE_ACTION_REPORT = 1002;
    public static final int NOTICE_ACTION_PATROL = 1003;
    public static final int NOTICE_ACTION_BIRTHDAY = 1004;
    public static final int NOTICE_ACTION_MEET = 1005;
    public static final int NOTICE_ACTION_APLLY_MEET = 1011;



    public SampleNoticeAdapter( List<SampleNotice> data) {
        super(R.layout.item_sample_notice_layout, data);
    }

    @Override
    protected void convert(BaseViewHolder holder, final SampleNotice sampleNotice) {
        holder.setText(R.id.tv_msg_title, sampleNotice.getTitle());
        holder.setText(R.id.tv_msg_content, sampleNotice.getContent());

        holder.setText(R.id.tv_msg_time, new SimpleDateFormat("HH:mm").format(sampleNotice.getTime()));


        if (sampleNotice.getKey() == 0) {
            holder.getView(R.id.item_action).setVisibility(View.GONE);
        } else {
            holder.getView(R.id.item_action).setVisibility(View.VISIBLE);
        }


        holder.getView(R.id.item_action).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                switch (sampleNotice.getKey()) {
                    case NOTICE_ACTION_SIGN:
                        mContext.startActivity(new Intent(mContext, AttendanceActivity.class));
                        break;
                    case NOTICE_ACTION_REPORT:
                        mContext.startActivity(new Intent(mContext, SelPostReportActivity.class));
                        break;
                    case NOTICE_ACTION_PATROL:
                        mContext.startActivity(new Intent(mContext, PatrolActivity.class));
                        break;
                    case NOTICE_ACTION_BIRTHDAY:
                        mContext.startActivity(new Intent(mContext, MatterNoticeActivity.class).putExtra("src", 1));
                        break;
                    case NOTICE_ACTION_MEET:
                        mContext.startActivity(new Intent(mContext, PlanMeetActivity.class));
                        break;
                    case NOTICE_ACTION_APLLY_MEET:
                        mContext.startActivity(new Intent(mContext, MatterNoticeActivity.class));
                        break;
                }
            }
        });
    }
}
